package com.hyl.jpademo.dao;

import com.hyl.jpademo.entity.Right;
import com.hyl.jpademo.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.sql.Struct;
import java.util.List;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2022/6/13 14:31
 **/
public interface SysRightResposity extends JpaRepository<Right,String> {

	public List<Right> findRightsByRolesOrderByRightCode(Role role); //根据角色


	@Query(value="Select r.* from sys_role_right  rl " +
			"LEFT JOIN sys_right r on rl.rf_right_code=r.right_code " +
			"where rf_role_id=?1 " +
			"ORDER BY r.right_code",
			nativeQuery= true)
	public List<Right> findByRoleId(Integer roleid);
}
